/***************************************************************************
 * 文件名：ReferenceConst
 * 功能：
 * 说明： 引用常量
 * -------------------------------------------------------------------------
 * 创建时间：2025/7/14 8:54:08
 * 创建人：葛浩
 * 邮箱： 2094733071@qq.com
 * =========================================================================
 *
 * 修改人：   
 * 修改时间：   
 * 修改说明：   
 ***************************************************************************/
using System.Collections.Generic;
using System.Linq;

namespace BuiltInTools
{
	/// <summary>
	/// 包引用类型
	/// </summary>
	public enum PackageType
	{
		/// <summary>
		/// 官方
		/// </summary>
		Offical = 0,
		/// <summary>
		/// 自定义
		/// </summary>
		Custom = 1,
		/// <summary>
		/// 第三方
		/// </summary>
		Others = 2,
	}

	/// <summary>
	///文件来源
	/// </summary>
	public class SourceTypeConst
	{
		public const string CSProj = ".csproj";
		public const string SLN = ".sln";

		private static readonly Dictionary<string, string> _Names = new Dictionary<string, string>
			{
				{CSProj, "CSharp项目文件" },
				{SLN, "VS解决方案文件" }
			};

		public static string[] GetAllKeys()
		{
			return _Names.Keys.ToArray();
		}

		public static string GetName(string key)
		{
			return key == null || !_Names.ContainsKey(key) ? key : _Names[key];
		}
	}

	/// <summary>
	/// 生成事件类型
	/// </summary>
	public class BuildEventConst
	{
		public const string Pre = "pre";

		public const string Post = "post";

		/// <summary>
		/// 生成前事件
		/// </summary>
		public const string PreBuildEvent = "PreBuildEvent";
		/// <summary>
		/// 生成后事件
		/// </summary>
		public const string PostBuildEvent = "PostBuildEvent";

		private static readonly Dictionary<string, string> _names = new Dictionary<string, string>()
		{
			{Pre, "生成前事件"},
			{Post, "生成后事件"},
		};

		/// <summary>
		/// 获取名称
		/// </summary>
		/// <returns></returns>
		public static string GetName(string key)
		{
			return key == null || !_names.ContainsKey(key) ? string.Empty : _names[key];
		}

		/// <summary>
		/// 常量列表
		/// </summary>
		/// <returns></returns>
		public static string[] GetAllKeys()
		{
			return _names.Keys.ToArray();
		}

		/// <summary>
		/// 键值列表
		/// </summary>
		/// <returns></returns>
		public static List<KeyValuePair<string, string>> GetList()
		{
			return _names.ToList();
		}
	}

	/// <summary>
	/// 引用类型常量
	/// </summary>
	public class ReferenceTypeConst
	{
		public const string Ref = "ref";
		public const string ProjRef = "projRef";
		public const string PkgRef = "pkgRef";

		public const string Reference = "Reference";
		public const string ProjectReference = "ProjectReference";
		public const string PackageReference = "PackageReference";

		private static readonly Dictionary<string, string> _Descriptions = new Dictionary<string, string>
			{
				{Ref, "程序集引用" },
				{ProjRef, "项目引用" },
				{PkgRef, "NuGet包引用" },
			};

		private static readonly Dictionary<string, string> _FullNames = new Dictionary<string, string>
			{
				{Ref, Reference },
				{ProjRef, ProjectReference },
				{PkgRef, PackageReference },
			};

		public static string GetFullName(string key)
		{
			return key == null || !_FullNames.ContainsKey(key) ? key : _FullNames[key];
		}

		public static string GetDescription(string key)
		{
			return key == null || !_Descriptions.ContainsKey(key) ? string.Empty : _Descriptions[key];
		}

		public static string GetAbbrName(string fullName)
		{
			return fullName == null || !_FullNames.Values.Contains(fullName) ? string.Empty : _FullNames.Where(p => p.Value == fullName).Select(p => p.Key).FirstOrDefault();
		}

		public static string[] GetAllKeys()
		{
			return _Descriptions.Keys.ToArray();
		}
		public static string[] GetAllFullNames()
		{
			return _FullNames.Values.ToArray();
		}

		public static List<KeyValuePair<string, string>> GetList()
		{
			return _Descriptions.Select(p => new KeyValuePair<string, string>(p.Key, p.Value)).ToList();
		}
	}

	/// <summary>
	/// 错误码
	/// </summary>
	public class EditorErrorCode
	{
		/// <summary>
		/// 参数异常
		/// </summary>
		public const int E0001 = -1;

		/// <summary>
		/// 返回状态消息文本
		/// </summary>
		private static readonly Dictionary<int, string> Names = new Dictionary<int, string>
		{
			{E0001,"参数异常"},
		};

		/// <summary>
		/// 常量列表
		/// </summary>
		/// <returns></returns>
		public static int[] GetAllKeys()
		{
			return Names.Keys.ToArray();
		}

		public static string GetName(int key)
		{
			if (Names.ContainsKey(key))
				return Names[key];
			else
				return string.Empty;
		}

		public static bool Contain(int key)
		{
			return Names.ContainsKey(key);
		}

		public static List<KeyValuePair<int, string>> GetList()
		{
			return Names.ToList();
		}
	}

	/// <summary>
	/// 包类型
	/// </summary>
	public class ItemGroupTypeConst
	{
		#region Const Fields

		/// <summary>
		/// 自定义
		/// </summary>
		public const string A = "A";
		/// <summary>
		/// 打包
		/// </summary>
		public const string B = "B";
		/// <summary>
		/// 第三方
		/// </summary>
		public const string C = "C";

		#endregion

		private static readonly Dictionary<string, string> _names = new Dictionary<string, string>()
		{
			{A, "自定义包"},
			{B, "打包的包"},
			{C, "第三方包"},
		};

		#region Methods

		/// <summary>
		/// 获取名称
		/// </summary>
		/// <returns></returns>
		public static string GetName(string key)
		{
			return key == null || !_names.ContainsKey(key) ? string.Empty : _names[key];
		}

		/// <summary>
		/// 常量列表
		/// </summary>
		/// <returns></returns>
		public static string[] GetAllKeys()
		{
			return _names.Keys.ToArray();
		}

		/// <summary>
		/// 键值列表
		/// </summary>
		/// <returns></returns>
		public static List<KeyValuePair<string, string>> GetList()
		{
			return _names.ToList();
		}

		#endregion
	}
}
